package cc.admin.common.db.table.writer;

import cc.admin.common.db.table.base.EtlWriter;
import cc.admin.common.db.table.entity.DbColumnType;
import cc.admin.common.db.table.entity.DbEntity;
import cc.admin.common.db.util.DbConstants;
/**
 * @author: ZhangHouYing
 * @date: 2018-06-24
 */
public class MysqlWriter extends EtlWriter {

	public MysqlWriter() {
		this.dbType = DbConstants.DB_NAME_MYSQL;
	}

	@Override
	public String writerSql(DbEntity dbEntity) {
		//mysql 字段都小写
		dbEntity.setId(dbEntity.getId().toLowerCase());
		dbEntity.getDbColumnList().forEach(dbColumn -> {
			dbColumn.setCode(dbColumn.getCode().toLowerCase());
		});
		return renderCreateTableSql("mysql.ftl", dbEntity);
	}

}
